DO
SYSTEM(ScrollToLine=-2)
DLG(B="How to solve a system of linear equations",
B="How to calculate the DOT PRODUCT of matrices m23*m32",
B="How to calculate the TRANSPOSED of a matrix",
B="How to calculate the INVERSE of a matrix",
B="How to calculate a UNITY matrix",
B="How to calculate the DETERMINANT of a matrix",
B='How to calculate the product "CONST*MATRIX"',
B='How to element-wise ADD "m32a+m32b"',
B='How to element-wise SUBTRACT "m32a-m32b"',
B='QUIT HicEst')
IF($txtRC == 'QUIT HicEst') SYSTEM(Quit=1)
IF($txtRC == "How to solve a system of linear equations")
DO
DLG(NumEdit=n,SYM,BG=990, B="n as is", B="Increase n", B="Decrease n", B="Exit")
IF($txtRC == "Exit") EXIT
n = n + ($txtRC == "Increase n") - ($txtRC == "Decrease n")
n = MAX(n, 1)
ARRAY(Name=A, CLeaR=1, Name=invers, Clear=1, Name=b, CLeaR=1, Name=x, CLeaR=1)
SET(A=(n,n), b=(n,1), x=(n,1))
DO i = n
b(i) = i
DO j = n
A(i,j) = RAN(1)
ENDDO
ENDDO
IF(n <= 10)
DLG(TI='Matrix A of "A*x=b"', Left=2/3, Hei=1/3, Top=0/3, Nr=1, Array=A)
DLG(TI='Vector b of "A*x=b"', Left=2/3, Hei=1/3, Top=1/3, Nr=2, Array=b, TI='row,B(row),')
ELSE
DLG(Kill=1, Kill=3)
ENDIF
LINALG(Matrix=A, INVerse=invers, Constants=b, ToDo=invers*b, Result=x)
DLG(TI='Vector x of "A*x=b"', Left=2/3, Hei=1/3, Top=2/3, Nr=3, Array=x, TI='row,x(row),')
SYSTEM(ScrollToLine = 0)
ENDDO
ELSEIF($txtRC == "How to calculate the DOT PRODUCT of matrices m23*m32")
m23 = ((1,2,3), (4,5,6))
m32 = ((11,12), (13,14), (15,16))
DLG(TI='Matrix m23 of "m23*m32"', Left=2/3, Hei=1/3, Top=0/3, Nr=1, Array=m23)
DLG(TI='Matrix m32 of "m23*m32"', Left=2/3, Hei=1/3, Top=1/3, Nr=2, Array=m32)
LINALG(Matrix=m23, Matrix=m32, ToDo=m23*m32, Result=dotProd)
SYSTEM(ScrollToLine = 1)
DLG(TI='Dot product of "m23*m32"', Left=2/3, Hei=1/3, Top=2/3, Array=dotProd)
ELSEIF($txtRC == "How to calculate the TRANSPOSED of a matrix")
m23 = ((1,2,3), (4,5,6))
DLG(TI='Matrix m23 to be transposed', Nr=2, Left=2/3, Hei=1/3, Top=1/3, Array=m23)
LINALG(Matrix=m23, Transpose=m32T)
SYSTEM(ScrollToLine = 1)
DLG(TI='The transposed matrix m32T', Left=2/3, Hei=1/3, Top=2/3, Array=m32T)
ELSEIF($txtRC == "How to calculate the INVERSE of a matrix")
m33 = ((1,2,3), (4,5,6), (7,8,1))
DLG(TI='Matrix m33 to be inversed', Nr=2, Left=2/3, Hei=1/3, Top=1/3, Array=m33)
LINALG(Matrix=m33, Inverse=m33I)
SYSTEM(ScrollToLine = 0)
SYSTEM(ScrollToLine = 1)
DLG(TI='The inversed matrix m33I', Left=2/3, Hei=1/3, Top=2/3, Array=m33I)
ELSEIF($txtRC == "How to calculate a UNITY matrix")
SET(unity=(6,6))
LINALG(Matrix=unity, Unity=uni)
SYSTEM(ScrollToLine = 1)
DLG(TI='The unity matrix for n=6', Left=2/3, Hei=1/3, Top=2/3, Array=uni)
ELSEIF($txtRC == "How to calculate the DETERMINANT of a matrix")
d22 = ( (1,2), (3,4) )
LINALG(Matrix=d22, DETerminant=det)
SYSTEM(ScrollToLine = 1)
DLG(TI='determinant(d22) = ' & det, Left=2/3, Hei=1/3, Top=2/3, Array=d22)
ELSEIF($txtRC == 'How to calculate the product "CONST*MATRIX"')
m32 = ((1,2), (3,4), (5,6))
DLG(TI='Matrix m32 of "const*m32"', Nr=2, Left=2/3, Hei=1/3, Top=1/3, Array=m32)
LINALG(Matrix=m32, ToDo=1.2*m32, Result=m32C)
SYSTEM(ScrollToLine = 1)
DLG(TI='1.2*m32', Left=2/3, Hei=1/3, Top=2/3, Array=m32C)
ELSEIF($txtRC == 'How to element-wise ADD "m32a+m32b"')
m32a = ((1,2), (3,4), (5,6))
m32b = ((.2,.3), (.4,.5), (.6,.7))
DLG(TI='Matrix m32a of "m32a+m32b"', Nr=1, Left=2/3, Hei=1/3, Top=0/3, Array=m32a)
DLG(TI='Matrix m32b of "m32a+m32b"', Nr=2, Left=2/3, Hei=1/3, Top=1/3, Array=m32b)
LINALG(Matrix=m32a, Matrix=m32b, ToDo=m32a+m32b, Result=m32eA)
SYSTEM(ScrollToLine = 1)
DLG(TI='Element-wise m32a+m32b', Left=2/3, Hei=1/3, Top=2/3, Array=m32eA)
ELSEIF($txtRC == 'How to element-wise SUBTRACT "m32a-m32b"')
m32a = ((1,2), (3,4), (5,6))
m32b = ((.2,.3), (.4,.5), (.6,.7))
DLG(TI='Matrix m32a of "m32a-m32b"', Nr=1, Left=2/3, Hei=1/3, Top=0/3, Array=m32a)
DLG(TI='Matrix m32b of "m32a-m32b"', Nr=2, Left=2/3, Hei=1/3, Top=1/3, Array=m32b)
LINALG(Matrix=m32a, Matrix=m32b, ToDo=m32a-m32b, Result=m32eS)
SYSTEM(ScrollToLine = 1)
DLG(TI='Element-wise m32a-m32b', Left=2/3, Hei=1/3, Top=2/3, Array=m32eS)
ENDIF
DLG(Kill=1, Kill=2, Kill=3)
ENDDO
END